/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxline.service;

import br.com.foxline.model.Endereco;
import br.com.foxline.util.Caracter;
import java.util.Date;
import javax.ejb.EJB;
import javax.ejb.Stateless;

/**
 *
 * @author ely
 */
@Stateless
public class EnderecoService extends GenericService<Endereco> {
    
    
    @EJB
    DneService dneService;
    
    public EnderecoService(){
        super(Endereco.class);
    }
     
    /**
     * <p>Verifica se existe algum endereço com o CEP informado</p>
     * 
     * @param cep - String contendo o cep a ser pesquisado
     * @return <b>Address</b>, caso seja encontrado algum endereço, ou <b>null</b>, caso contrário.
     */
    public Endereco existCep(Endereco a){
        return dneService.existCep(a);
    }
     
    @Override
    public void save(Endereco endereco){
        endereco.setCep(Caracter.removecaracter(endereco.getCep()));
        endereco.setCreateAt(new Date());
        super.save(endereco);
    }
}
